$(() => {
    const token = GetQueryString("token");
    const area_id = GetQueryString("area_id");
    const recommend_position = GetQueryString("recommend_position");
    let page = 1;
    let pageSize = 16;
    moreBrand(page);

    function moreBrand(page) {
        $.ajax({
            type: "post",
            url: url,
            data: { 'method': 'Company|more_company', 'area_id': area_id, 'recommend_position': recommend_position, 'p': page, 'page_size': pageSize },
            dataType: 'json',
            success: function(res) {
                if (res.status == 1) {
                    let data = res.data;
                    let html = '';
                    $('.hetitle').html(data.title);
                    data.list.forEach(item => {
                        if (item.company_level >= 1) {
                            html += `<a href="shop_details_company.html?company_id=${item.id}&token=${token}" class="inlist1link">`
                        } else {
                            html += `<a href="shop_details.html?company_id=${item.id}&token=${token}" class="inlist1link">`
                        }
                        html += `<img src="${item.company_poster_thumb}" alt="${item.company_name}" class="inlistpic">
                    </a>
                    `;
                    })
                    if (data.list.length < pageSize) {
                        $('.notMore').css('display', 'flex');
                    }
                    $('.inlinst1').append(html);
                }
            }
        })
    }


    // 下拉加载更多
    $(window).scroll(function() {
        if ($(document).scrollTop() >= $(document).height() - $(window).height() - 1) {
            // console.log('我到底了');
            if ($('.notMore').css('display') != "flex") {
                page++;
                moreBrand(page);
            }
        }
    })
})